<?php
	// if the file failed to open...
	if ($_FILES["file"]["error"] > 0)
		echo "Error" . $_FILES["file"]["error"] . "<br />";
	else
	{
		// Display the file information
		echo "Upload: " . $_FILES["file"]["name"] . "<br />";			// name of the uploaded file
		echo "Type: " . $_FILES["file"]["type"] . "<br />";				// uploaded file's type
		echo "Size: " . $_FILES["file"]["size"] . " KB<br />";			// uploaded file's size (in Bytes)
		echo "Stored in: " . $_FILES["file"]["tmp_name"] . "<br />";	// location of the uploaded file
		
		// Now lets save the file too!
		
		// First check if the file is already in the stored directory
		if (file_exists("upload/ " . $_FILES["file"]["name"]))
			echo "<br /><br />File already exists!!";
		else
		{
			// Pretty straight forward...move_uploaded_file(string path, string new_path)
			move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
			echo "<br /><br />File stored in: upload/ " . $_FILES["file"]["name"];
		}
		
	}	
?>